<template>
  <div class="consultationMain">
    <div style="width: 100%;min-height: 95vh;" class="consultationWrap">
      <headerBack :hasBack="hasBack" @btnclick="goSearch('./search')">
        <b class="my-center" slot="my-center">咨询</b>
        <span class="my-right" slot="my-right"></span>
      </headerBack>
      <!-- <collage ref="collageChild" :items1="areaData" v-on:listenToChild="showMsgFromSec1"></collage> -->
      <scroller style="top:0.88rem;" :on-refresh="refresh" :on-infinite="infinite" ref="scrollerBottom" class="my-scroller">
        <div style="width: 7.5rem;height: auto;">
          <seek-info :advisories="advisoriesList"></seek-info>
        </div>
      </scroller>
    </div>
  </div>
</template>

<script>
import { getRanking } from '~/api/colleges'
import ls from 'store2'
import headerBack from '~/components/headerBack'
import collage from '~/components/Collage'
import seekInfo from '~/components/seekInfo'
import { getAdvisories } from '~/api/school'
import { Loading } from 'vux'
export default {
  components: {
    Loading,
    collage,
    headerBack,
    seekInfo
  },
  data() {
    return {
      advisoriesList: [],
      hasBack: true,
      stySty: '',
      //   options: {
      //     provinceIds: [],
      //     attrs: [],
      //     labels: [],
      //     levels: [],
      //     opsort: 'combined',
      //     batchs: []
      //   },
      //   bottomCount: 1,
      currentPage: 1,
      areaData: [],
      limit: 15
    }
  },
  created() {
    this.commonJs.accectAppParame()
  },
  mounted() {
    this.$visit('AcademyList')
    // this.$refs.collageChild.showBatch()
    this.getAdvisories()
  },
  methods: {
    goSearch(uri) {
      this.$router.push({ path: uri + '?provincesId=' + this.$route.query.provincesId })
    },
    getAdvisories() {
      this.$loading('open')
      getAdvisories(1, this.limit, this.$route.query.provincesId, '')
        .then(res => {
          this.advisoriesList = res.data
          this.totalPages = Math.ceil(res.meta.total / this.limit)
        })
        .finally(() => {
          this.$hideLoading()
        })
    },
    showMsgFromSec1(data) {
      //   this.options = data
      //   this.bottomCount = 1
      this.$refs.scrollerBottom.scrollTo(0, 0, false)
      //   this.$loading('open')
      //   sessionStorage.setItem('options', JSON.stringify(this.options))
    },

    infinite(done) {
      if (this.currentPage < this.totalPages) {
        this.currentPage = this.currentPage + 1
        getAdvisories(this.currentPage, this.limit, this.$route.query.provincesId, '').then(res => {
          let newArr = res.data
          this.advisoriesList = this.advisoriesList.concat(newArr)
          this.totalPages = Math.ceil(res.meta.total / this.limit)
          done()
        })
      } else {
        done(true)
        return
      }
    },
    refresh(done) {
      setTimeout(() => {
        this.onFetching = false
        this.stySty = 'z-index:10000;opacity: 1;'
        let _this = this
        setTimeout(() => {
          _this.stySty = 'z-index:-1;opacity: 0;'
        }, 2000)

        done()
      }, 1500)
    }
  }
}
</script>

<style lang="less">
.consultationWrap {
  background: #fff;
  .first-words {
    width: 100%;
    height: 0.8rem;
    background: #ffad0d;
    position: absolute;
    z-index: -1;
    opacity: 0;
    text-align: center;
    line-height: 0.8rem;
    font-size: 0.3rem;
    color: #fff;
    left: 0;
    top: 1.68rem;
  }

  .my-center {
    font-weight: 600;
  }
  .my-right {
    display: inline-block;
    width: 0.4rem;
    height: 0.4rem;
    text-align: right;
    background: url('~@/static/sprite/other_sprites.png') -1.96rem -2.2rem;
    background-size: 4.68rem 4.08rem;
  }

  .demo1-item {
    border: 1px solid #ececec;
    border-radius: 2px;
  }

  .demo1-item-selected {
    border: 1px solid @mainColor;
    border-radius: 2px;
    color: @mainColor;
  }
}
.consultationMain {
  width: 100%;
  height: 100vh;
  font-size: 0.3rem;
}
</style>
